package com.caocaog.market.finance.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.caocaog.market.finance.entity.FinanceGroup;
import com.caocaog.market.finance.entity.FinanceLine;
import com.caocaog.market.finance.entity.MkBillLine;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface FinanceGroupMapper extends BaseMapper<FinanceGroup> {

    IPage<FinanceGroup> queryFinanceGroupPage(Page<FinanceGroup> page,
                                              @Param(Constants.WRAPPER) Wrapper<FinanceGroup> queryWrapper,
                                              @Param("orderNo") String orderNo,
                                              @Param("siteName") String siteName);

    @Delete("DELETE FROM mk_finance_group; DELETE FROM mk_finance_line; DELETE FROM mk_finance_group_line_merge;")
    void deleteAllFinance();

    @Select("select * from (select order_no, count(1) as `count` from mk_bill_line as line where del_flag = 0  GROUP BY line.order_no) as t where count>3")
    List<MkBillLine> queryDuplicateData();


    @Deprecated
    List<FinanceLine> getFinanceLineListIsNullSystemPCT();
}
